package com.example.sentinel.provider;

import cn.hutool.core.util.RandomUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 服务者控制器
 *
 * @author beerus
 * @date 2020/6/14 17:52
 */
@Slf4j
@RestController
@RequestMapping("/provider")
public class ProviderController {

    @GetMapping("/get/username")
    public String getUserName() throws InterruptedException {
        if(RandomUtil.randomInt(1,7) == 2){
            throw new IllegalArgumentException("provider error");
        }else if(RandomUtil.randomInt(1,5) == 3){
            int i = 1/0;
        }else if(RandomUtil.randomInt(1,5) == 4){
            Thread.sleep(5000);
        }
        return "userName";
    }

}
